/////////////////////////////////////////////////////////////////////////////
// Name:        valgenvariant.h
// Purpose:     wxGenericVariantValidator class
// Author:      Julian Smart
// Modified by:
// Created:     July 27th 2007
// RCS-ID:      $Id: valgenvariant.h,v 1.1 2007/07/31 21:24:53 anthemion Exp $
// Copyright:   (c) Julian Smart
// Licence:     New BSD License
/////////////////////////////////////////////////////////////////////////////

#ifndef _WX_VALGENVARIANTH__
#define _WX_VALGENVARIANTH__

#include "wx/valgen.h"
#include "wx/variant.h"

#if wxUSE_VALIDATORS

class WXDLLEXPORT wxGenericVariantValidator: public wxGenericValidator
{
    DECLARE_CLASS(wxGenericVariantValidator)
public:
    wxGenericVariantValidator(wxVariant* val = NULL);
    wxGenericVariantValidator(const wxGenericVariantValidator& copyFrom);
    
    virtual ~wxGenericVariantValidator(){}
    
    // Make a clone of this validator (or return NULL) - currently necessary
    // if you're passing a reference to a validator.
    // Another possibility is to always pass a pointer to a new validator
    // (so the calling code can use a copy constructor of the relevant class).
    virtual wxObject *Clone() const { return new wxGenericVariantValidator(*this); }
    bool Copy(const wxGenericVariantValidator& val);
    
    // Called when the value in the window must be validated.
    // This function can pop up an error message.
    virtual bool Validate(wxWindow * WXUNUSED(parent)) { return true; }
    
    // Called to transfer data to the window
    virtual bool TransferToWindow();
    
    // Called to transfer data to the window
    virtual bool TransferFromWindow();
    
protected:
    
    // Initialize
    void Init();
    
    // Initialize the actual data variables from the variant type
    virtual bool InitializeFromVariant();
    
    wxVariant*    m_variant;
    
    int           m_int;
    bool          m_bool;
    wxString      m_string;
    
private:
    // Cannot use
    //  DECLARE_NO_COPY_CLASS(wxGenericVariantValidator)
    // because copy constructor is explicitly declared above;
    // but no copy assignment operator is defined, so declare
    // it private to prevent the compiler from defining it:
    wxGenericVariantValidator& operator=(const wxGenericVariantValidator&);
};

#endif
  // wxUSE_VALIDATORS

#endif
  // _WX_VALGENVARIANT_
